﻿@{
    ViewBag.Title = "Ranking";
}

<h2><a href="/Ranking">Ranking indywidualny</a> | Ranking grupowy</h2>
<h3>Proszę wybrać parametry:</h3>

<form id="rankingForm" action="/Ranking/Team" method="get">

    <label for="season">Sezon:</label>
    <select id="season" name="season_id">
        @foreach (var item in ViewBag.SeasonsList)
        {
            <option value="@item.SeasonId"@(ViewBag.Season.SeasonId == item.SeasonId ? " selected='selected'" : "")>
            @item.SeasonName
            </option>
        }
    </select>
    <input type="submit" value="Pokaż" />
</form>

@if (ViewBag.IsTeams) 
{

    <table id="table2" class="tablesorter">
        <thead>
            <tr>
                <th>Drużyna</th>
                <th>Mecze</th>
                <th>Punkty (suma)</th>
                <th>Punkty (średnia)</th>
                <th class="aos">Faule (suma)</th>
                <th class="aos">Faule (średnia)</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in ViewBag.TeamsList)
            {
                <tr>
                    <td><a href="/Team/Details/@item.Team.TeamId">@item.Team.TeamName</a></td>
                    <td>@item.TotalMatches</td>
                    <td>@item.TotalPoints</td>
                    <td>@item.AveragePoints</td>
                    <td class="aos">@item.TotalFauls</td>
                    <td class="aos">@item.AverageFauls</td>
                </tr>
            }
        </tbody>
    </table>
    <a href="#" class="ranking_more">Więcej szczegółów</a>

    <script type="text/javascript">
        $(document).ready(function () {
            $.tablesorter.defaults.widgets = ['zebra'];
            $("table").tablesorter({
                sortList: [[2, 1]]
            });

            var ranking_more = false;
            $('.ranking_more').click(function (e) {
                e.preventDefault();
                if (ranking_more) {
                    $('.aos').hide();
                    ranking_more = false;
                    $(this).html('Więcej szczegółów');
                } else {
                    $('.aos').show();
                    ranking_more = true;
                    $(this).html('Mniej szczegółów');
                }
            });
        });
    </script>

}
else
{
    <b>Brak drużyn w tym sezonie.</b>    
}